package com.aidex.biz.service;

import com.aidex.biz.domain.Customer;
import com.aidex.biz.domain.JinjianInfo;
import com.aidex.biz.domain.PushRuleUser;
import com.aidex.biz.domain.bo.BusinessSetBo;
import com.aidex.biz.domain.vo.CustomerExpertVo;
import com.aidex.biz.domain.vo.YuanGongGongziVo;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.service.BaseService;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 左心房客户推送信息Service接口
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2023-04-03
 */
public interface CustomerService extends BaseService<Customer> {

    public PageInfo<Customer> selectToHongHai15(Customer customer);

    /**
     * 批量删除左心房客户推送信息
     *
     * @param ids 需要删除的左心房客户推送信息ID集合
     * @return 结果
     */
    public int deleteCustomerByIds(String[] ids);

    /**
     * 获取最大编号
     *
     * @param customer 左心房客户推送信息
     * @return 结果
     */
    public int findMaxSort(Customer customer);

    /**
     * 根据手机查询客户信息
     *
     * @param customer
     * @return
     */
    public boolean findCustomerByphone(Customer customer);

    /**
     * 根据手机查询客户信息
     *
     * @param phone
     * @return
     */
    public Customer findCustomerByphone(String phone);

    public Customer findCustomerByphone(Customer customer, boolean is);

    /**
     * 保存推送的客户信息
     *
     * @param customer
     * @return
     */
    public Map savePushCustomer(Customer customer);


    /**
     * 手动分配分配客户到用户
     *
     * @param customer
     */
    public int shareCustomer(Customer customer, SysUser sysUser);

    /**
     * 根据规则分配客户到用户
     *
     * @param customer
     */
    public int shareCustomerByRule(Customer customer, PushRuleUser user);

    /**
     * 手动分配分配我的客户到用户
     *
     * @param customer
     */
    public int myShareCustomer(Customer customer, SysUser sysUser);

    /**
     * 找到下个分配用户
     *
     * @param customer
     * @return
     */
    public SysUser findNextShareUser(Customer customer);

    /**
     * @return 查询一个为分配的用户
     */
    public Customer findOne();


    /**
     * @return 查询一个撞库未分配的用户
     */
    public Customer findZkOne();

    /**
     * @return 查询一个未接待分配的用户
     */
    public Customer findWjOne();

    /**
     * 导入客户信息
     *
     * @param customers
     * @return
     */
    public String importData(List<Customer> customers, String status) throws InterruptedException;

    /**
     * 修改客户状态
     *
     * @param customer
     * @return
     */
    public Integer updateStatus(Customer customer);

    public Customer findByPhone(Customer customer);

    public List<Customer> findByNameOrPhone(Customer customer);

    public PageInfo<Customer> findListXieZu(Customer customer);

    public PageInfo<Customer> findgonghaiList(Customer customer);

    public PageInfo<Customer> findMyList(Customer customer);

    public PageInfo<Customer> findChengJiaoList(Customer customer);


    public PageInfo<Customer> findXiansuoList(Customer customer);

    /**
     * 查找待跟进客户
     *
     * @param customer
     * @return
     */
    public PageInfo<Customer> findDaigenjinList(Customer customer);

    /**
     * 关联查询客户
     *
     * @param customer
     * @return
     */
    public PageInfo<Customer> findCustomerWithJoinList(Customer customer);

    /**
     * 线索池或者我的客户状态
     *
     * @param customer
     * @return
     */
    public Integer updateMyStatus(Customer customer);

    public List<CustomerExpertVo> findAllExportList();

    /**
     * 工资统计
     */
    public List<YuanGongGongziVo> yuangonggongzitongji(Customer customer);

    public PageInfo<Customer> ysfindPage(Customer customer);

    /**
     * 已成交客户自动变更设置
     */
    public void updateStatusByJinJianStatus(JinjianInfo jinjianInfo);


    /**
     * /*我的客户48内，没有跟进，去公海   锁住的客户不准去公海
     */
    public void updateStatusToHongHai48(BusinessSetBo businessSetBo);

    /**
     * /*我的客户 15天内，没有跟进  锁住的客户不准去公海
     */
    public void updateStatusToHongHai15(BusinessSetBo businessSetBo);

    /**
     * /*我的客户3天内，没有跟进 锁住的客户不准去公海
     */
    public void updateStatusToHongHai3(BusinessSetBo businessSetBo);

    /**
     * *线索池内，没有跟进，去公海*
     */
    public void updateStatusToHongHaiXianSuoChi(BusinessSetBo businessSetBo);


    /**
     * 取消标记重复客户
     */
    public void updateStatusCancelRep(BusinessSetBo businessSetBo);

    /**
     * 取消锁定
     */
    public void updateStatusCancelLock(BusinessSetBo businessSetBo);


    /**
     * 查询已经锁客多少人
     */
    public Integer findLocks(Customer customer);


    /**
     * 锁客
     */
    public Integer lockCustomer(Customer customer);


    /**
     * @param businessSetBo
     * @return
     */
    public List<Customer> selectToHongHai48(BusinessSetBo businessSetBo);

    /**
     * @param businessSetBo
     * @return
     */
    public List<Customer> selectToHongHai3(BusinessSetBo businessSetBo);

    /**
     * @param businessSetBo
     * @return
     */
    public List<Customer> selectToHongHai15(BusinessSetBo businessSetBo);


    /**
     * @param businessSetBo
     * @return
     */
    public List<Customer> selectIsRepToTime(BusinessSetBo businessSetBo);

    /**
     * @param businessSetBo
     * @return
     */
    public List<Customer> selectIsLockToTime(BusinessSetBo businessSetBo);

    /**
     * @param jinjianInfo
     * @return
     */
    public List<Customer> selectCustomerIdByJinJianStatus(JinjianInfo jinjianInfo);

    /**
     * 10分钟内未跟进自动转入公海
     *
     * @param businessSetBo
     * @return
     */
    public List<Customer> findNotGen(BusinessSetBo businessSetBo);


    /**
     * 重新分配
     */
    public Integer updateNotGen(Customer customer);

    /**
     * 员工离职 客户转入公海
     *
     * @param ids 员工ID
     * @return
     */
    public int deleteUsersToGongHai(String[] ids);


    /**
     * 融享客入库
     */
    public int insertRongXinKe(String orderNo);

    public Integer updateIsHeart(Customer customer);


    /**
     * 撞库后更新状态-分配客户
     *
     * @param customer 查询到的客户
     * @param laiyuan  撞库来源
     * @param phone    撞库号码（一般是前面几位）
     * @param zkCount  撞库数量
     */
    public void updateStatusIfExistedAfterCheck(Customer customer, String laiyuan, String phone, Integer zkCount);

    public Customer findGonghaiOne();

    /**
     * 撞库后记录动态
     *
     * @param customer
     * @param newLaiyuan
     * @return
     */
    public void savePushCustomerZhuangku(Customer customer, String newLaiyuan);

    /**
     * 潜在客户（撞库客户）
     *
     * @param customer
     * @return
     */
    public PageInfo<Customer> findZhuangKuList(Customer customer);

    public PageInfo<Customer> findMyReceiveList(Customer customer);

    /**
     * 查询未接超时流转的客户
     *
     * @param businessSetBo
     * @return
     */
    public List<Customer> findWjExceedTimeToShareList(BusinessSetBo businessSetBo);

    /**
     * 查询未接超次数流转的客户
     *
     * @param businessSetBo
     * @return
     */
    public List<Customer> findWjExceedCountToShareList(BusinessSetBo businessSetBo);

    /**
     * 系统协助
     *
     * @param customer
     * @param user
     * @return
     */
    public int xieZhuCustomer(Customer customer, PushRuleUser user);

    /**
     * 批量分配给他人
     *
     * @param customer
     * @param user
     * @return
     */
    public int batchShareCustomersToUserByIds(@Param("customer") Customer customer, @Param("user") SysUser user);

    /**
     * 批量更新状态为未接待流转
     *
     * @param list
     * @return
     */
    public int updateStatusToWeiJie(List<Customer> list);

    /**
     * 查询待流转去公海客户
     *
     * @param customer
     * @return
     */
    public PageInfo<Customer> findWillToGongHaiList(Customer customer);

    /**
     * 未接待流转客户
     *
     * @param customer
     * @return
     */

    public PageInfo<Customer> findWeiJieWillToShareList(Customer customer);
}
